import Taro, { Component } from '@tarojs/taro'
import { Swiper, SwiperItem, Image, View, Text } from '@tarojs/components'
import '../../assets/common.scss'
import CommonJs from '../../utils/common'
import './persinfo.scss'

export default class Index extends Component {

  constructor(props) {
    super(props);
    this.state = {
      res:{},
      isload:0,
      cluster:"",
      userinfo:Taro.getStorageSync('userinfo'), 
	  qylist:[]
    }
  }

  config = {
    navigationBarTitleText: '加载中'
  }

  opendetails(url,id){
    this.$preload('pagename',id);
    CommonJs.openTo(url);
  }
  

  componentWillMount () {
    // console.log(this.$router.preload.pagename)
    this.getdata();
    this.getmycluster();
	this.getqylist()
  }

  componentDidMount () { }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }


  getdata(){
    var _this=this;
    var pagename = _this.$router.preload.pagename;
    var date = {
        userId:pagename
    }
    CommonJs.ajaxRequest('/user/getUserParramById',date,'GET',function(res){
        _this.setState({
          res: res,
          isload: 1
        });
        Taro.setNavigationBarTitle({title:"详细信息"})
    })
  }
  getmycluster(){
  	var _this=this;
    var pagename = _this.$router.preload.pagename;
    var url="/cluster/clustersall?userId="+pagename
    CommonJs.ajaxRequest(url,'','GET',function(res){
	    _this.setState({
	      cluster:res.content,
	      isload: 1
	    });
    })
  }
  getqylist(){
	var url='/profit/papi/v1.9/parent-region-relate?page=0&size=1000'
	var _this=this
  	CommonJs.ajaxRequest(url,'','GET',function(res){
      _this.setState({
        qylist: res.data.list
      });
  	},'wfw')
  }
  
  render () {
    const res = this.state.res
    const cluster = this.state.cluster
	const qylist=this.state.qylist
    return (
    	<View className='page' style={this.state.isload==1?'display:block':'display:none'}>
	      <View className='qun-banner'>

            <View className='qun-xni'>
                <View className='qun-xnto'>

                    <View className='qun-zoyn'>
                        <View className='qun-toimg'>
                            <Image className='qun-toimgs' mode='scaleToFill' src={res.photo?res.photo:'https://minichat.g2ma.com/kedouimg/A6984900727459logo.png'}></Image>
                        </View>
                        <View className='qun-toxn'>
                            <Text className='qun-mce qun-mcebod'>{res.nickName}</Text>
                            <Text className='qun-mce qun-mcetop'>{res.note?res.note:"这家伙很懒 ，什么都没留下"}</Text>
                        </View>
                    </View>

                </View>
            </View>

            <View className='qun-infoul'>
                <View className='qun-infoli'>
                    <Text className='qun-zaho'>账号</Text>
                    <Text className='qun-zaxnx'>{res.name?res.name:"暂无"}</Text>
                </View>
                <View className='qun-infoli' style="display:none;">
                    <Text className='qun-zaho'>微信号</Text>
                    <Text className='qun-zaxnx'>{res.company?res.company:"暂无"}</Text>
                </View>
                <View className='qun-infoli'>
                    <Text className='qun-zaho'>地区</Text>
                    <Text className='qun-zaxnx'>{res.address?res.address:"暂无"}</Text>
                </View>
                <View className='qun-infoli'>
                    <Text className='qun-zaho'>性别</Text>
                    <Text className='qun-zaxnx'>{res.sex==2?"女":"男"}</Text>
                </View>
                <View className='qun-infoli'>
                    <Text className='qun-zaho'>加入时间</Text>
                    <Text className='qun-zaxnx'>{CommonJs.FormatDate(res.createAt,2)}</Text>
                </View>
            </View>
			<View className='qun-infoul' style={qylist.length>0?"border-top:10px solid #f1f1f1;border-bottom:10px solid #f1f1f1":"display:none"}>
                <View className='qun-infoli'>
                    <Text className='qun-zaho'>我绑定的区域</Text>
                    <Text className='qun-zaxnx'></Text>
                </View>
                <View className='qun-infoli' style='height:auto;display:block;'>
                  <View className='qun-jaqn qun-jaqnts'>
                    <View className='qun-inone' style='display:block;max-width:100%;'>
					{qylist.map((item, index) => ( 
                      <Text decode='true' className='qun-inonename'>{item.provinceName}{item.cityName}{item.areaName}{item.countyName?item.countyName:''}</Text>
                     ))}
                    </View>
                  </View>
                </View>
                

            </View>

            <View className='qun-infoul'>
                <View className='qun-infoli'>
                    <Text className='qun-zaho'>加入的群</Text>
                    <Text className='qun-zaxnx'></Text>
                </View>
                <View className='qun-snqnzanwu' style={cluster.length > 0 ? 'display:none;' : 'display:block;'}>暂无数据</View>
                {cluster.map((item, index) => ( 
                <View className='qun-infoli qun-infoheg'>
                  <View className='qun-jaqn'>
                    <View className='qun-jaqnimg'>
                      <Image className='qun-toimgs' mode='scaleToFill' src={item.photo?item.photo:'https://minichat.g2ma.com/kedouimg/A6984900727459logo.png'}></Image>
                    </View>
                    <View className='qun-inone'>
                      <Text decode='true' className='qun-inonename'>{item.name}</Text>
                      <Text className='qun-inonecol' decode='true'>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;{item.clusterCount}人</Text>
                    </View>
                  </View>
                </View>
                ))}

            </View>

	      </View>
      </View>
    )
  }
}